/**
 * 
 */
package br.com.ufrn.aipetro.ga.model.persist.hibernate;

import java.util.List;

import org.hibernate.Session;

import br.com.ufrn.aipetro.ga.domain.entity.mesh.Mesh;
import br.com.ufrn.aipetro.ga.domain.entity.plant.Plant;
import br.com.ufrn.aipetro.ga.model.persist.hibernate.util.HibernateUtil;
import br.com.ufrn.aipetro.ga.persist.interfaces.MeshDao;

/**
 * 
 * @author Lucas
 *
 */
public class HibernateMeshDao extends MeshDao {
	
	Session session;
	Class entityClass;
	
	public HibernateMeshDao(Class entityClass) {
		this.session = HibernateUtil.getSessionFactory().getCurrentSession();
		this.entityClass = entityClass;
		basicDao = new HibernateBasicDao<Mesh>(session, entityClass);
	}
	
	@Override
	public List<Mesh> searchByPlant(Plant plant) {
		return (List<Mesh>)session.createQuery("from Mesh m where m.plant = :plant ")
				.setEntity("plant", plant)
				.list();
	}
	
}
